import { cloneDeep } from '@vben/utils';

import { $t } from '#/locales';

export function getChartOptions(activeTabName: any, res: any): any {
  switch (activeTabName) {
    case 'contactCountRank': {
      return {
        dataset: {
          dimensions: ['nickname', 'count'],
          source: cloneDeep(res).reverse(),
        },
        grid: {
          left: 20,
          right: 50,
          bottom: 20,
          containLabel: true,
        },
        legend: {
          top: 50,
        },
        series: [
          {
            name: $t('views.crm.statistics.rank.chartOptions.contactCountRank.seriesName'),
            type: 'bar',
          },
        ],
        toolbox: {
          feature: {
            dataZoom: {
              yAxisIndex: false, // 数据区域缩放：Y 轴不缩放
            },
            brush: {
              type: ['lineX', 'clear'], // 区域缩放按钮、还原按钮
            },
            saveAsImage: { show: true, name: $t('views.crm.statistics.rank.chartOptions.contactCountRank.saveAsImageName') }, // 保存为图片
          },
        },
        tooltip: {
          trigger: 'axis',
          axisPointer: {
            type: 'shadow',
          },
        },
        xAxis: {
          type: 'value',
          name: $t('views.crm.statistics.rank.chartOptions.contactCountRank.xAxisName'),
        },
        yAxis: {
          type: 'category',
          name: $t('views.crm.statistics.rank.chartOptions.contactCountRank.yAxisName'),
          nameTextStyle: {
            align: 'left'
          }
        },
      };
    }
    case 'contractCountRank': {
      return {
        dataset: {
          dimensions: ['nickname', 'count'],
          source: cloneDeep(res).reverse(),
        },
        grid: {
          left: 20,
          right: 50,
          bottom: 20,
          containLabel: true,
        },
        legend: {
          top: 50,
        },
        series: [
          {
            name: $t('views.crm.statistics.rank.chartOptions.contractCountRank.seriesName'),
            type: 'bar',
          },
        ],
        toolbox: {
          feature: {
            dataZoom: {
              yAxisIndex: false, // 数据区域缩放：Y 轴不缩放
            },
            brush: {
              type: ['lineX', 'clear'], // 区域缩放按钮、还原按钮
            },
            saveAsImage: { show: true, name: $t('views.crm.statistics.rank.chartOptions.contractCountRank.saveAsImageName') }, // 保存为图片
          },
        },
        tooltip: {
          trigger: 'axis',
          axisPointer: {
            type: 'shadow',
          },
        },
        xAxis: {
          type: 'value',
          name: $t('views.crm.statistics.rank.chartOptions.contractCountRank.xAxisName'),
        },
        yAxis: {
          type: 'category',
          name: $t('views.crm.statistics.rank.chartOptions.contractCountRank.yAxisName'),
          nameTextStyle: {
            align: 'left'
          }
        },
      };
    }
    case 'contractPriceRank': {
      return {
        dataset: {
          dimensions: ['nickname', 'count'],
          source: cloneDeep(res).reverse(),
        },
        grid: {
          left: 20,
          right: 50,
          bottom: 20,
          containLabel: true,
        },
        legend: {
          top: 50,
        },
        series: [
          {
            name: $t('views.crm.statistics.rank.chartOptions.contractPriceRank.seriesName'),
            type: 'bar',
          },
        ],
        toolbox: {
          feature: {
            dataZoom: {
              yAxisIndex: false, // 数据区域缩放：Y 轴不缩放
            },
            brush: {
              type: ['lineX', 'clear'], // 区域缩放按钮、还原按钮
            },
            saveAsImage: { show: true, name: $t('views.crm.statistics.rank.chartOptions.contractPriceRank.saveAsImageName') }, // 保存为图片
          },
        },
        tooltip: {
          trigger: 'axis',
          axisPointer: {
            type: 'shadow',
          },
        },
        xAxis: {
          type: 'value',
          name: $t('views.crm.statistics.rank.chartOptions.contractPriceRank.xAxisName'),
        },
        yAxis: {
          type: 'category',
          name: $t('views.crm.statistics.rank.chartOptions.contractPriceRank.yAxisName'),
          nameTextStyle: {
            align: 'left'
          }
        },
      };
    }
    case 'customerCountRank': {
      return {
        dataset: {
          dimensions: ['nickname', 'count'],
          source: cloneDeep(res).reverse(),
        },
        grid: {
          left: 20,
          right: 50,
          bottom: 20,
          containLabel: true,
        },
        legend: {
          top: 50,
        },
        series: [
          {
            name: $t('views.crm.statistics.rank.chartOptions.customerCountRank.seriesName'),
            type: 'bar',
          },
        ],
        toolbox: {
          feature: {
            dataZoom: {
              yAxisIndex: false, // 数据区域缩放：Y 轴不缩放
            },
            brush: {
              type: ['lineX', 'clear'], // 区域缩放按钮、还原按钮
            },
            saveAsImage: { show: true, name: $t('views.crm.statistics.rank.chartOptions.customerCountRank.saveAsImageName') }, // 保存为图片
          },
        },
        tooltip: {
          trigger: 'axis',
          axisPointer: {
            type: 'shadow',
          },
        },
        xAxis: {
          type: 'value',
          name: $t('views.crm.statistics.rank.chartOptions.customerCountRank.xAxisName'),
        },
        yAxis: {
          type: 'category',
          name: $t('views.crm.statistics.rank.chartOptions.customerCountRank.yAxisName'),
          nameTextStyle: {
            align: 'left'
          }
        },
      };
    }
    case 'followCountRank': {
      return {
        dataset: {
          dimensions: ['nickname', 'count'],
          source: cloneDeep(res).reverse(),
        },
        grid: {
          left: 20,
          right: 50,
          bottom: 20,
          containLabel: true,
        },
        legend: {
          top: 50,
        },
        series: [
          {
            name: $t('views.crm.statistics.rank.chartOptions.followCountRank.seriesName'),
            type: 'bar',
          },
        ],
        toolbox: {
          feature: {
            dataZoom: {
              yAxisIndex: false, // 数据区域缩放：Y 轴不缩放
            },
            brush: {
              type: ['lineX', 'clear'], // 区域缩放按钮、还原按钮
            },
            saveAsImage: { show: true, name: $t('views.crm.statistics.rank.chartOptions.followCountRank.saveAsImageName') }, // 保存为图片
          },
        },
        tooltip: {
          trigger: 'axis',
          axisPointer: {
            type: 'shadow',
          },
        },
        xAxis: {
          type: 'value',
          name: $t('views.crm.statistics.rank.chartOptions.followCountRank.xAxisName'),
        },
        yAxis: {
          type: 'category',
          name: $t('views.crm.statistics.rank.chartOptions.followCountRank.yAxisName'),
          nameTextStyle: {
            align: 'left'
          }
        },
      };
    }
    case 'followCustomerCountRank': {
      return {
        dataset: {
          dimensions: ['nickname', 'count'],
          source: cloneDeep(res).reverse(),
        },
        grid: {
          left: 20,
          right: 50,
          bottom: 20,
          containLabel: true,
        },
        legend: {
          top: 50,
        },
        series: [
          {
            name: $t('views.crm.statistics.rank.chartOptions.followCustomerCountRank.seriesName'),
            type: 'bar',
          },
        ],
        toolbox: {
          feature: {
            dataZoom: {
              yAxisIndex: false, // 数据区域缩放：Y 轴不缩放
            },
            brush: {
              type: ['lineX', 'clear'], // 区域缩放按钮、还原按钮
            },
            saveAsImage: { show: true, name: $t('views.crm.statistics.rank.chartOptions.followCustomerCountRank.saveAsImageName') }, // 保存为图片
          },
        },
        tooltip: {
          trigger: 'axis',
          axisPointer: {
            type: 'shadow',
          },
        },
        xAxis: {
          type: 'value',
          name: $t('views.crm.statistics.rank.chartOptions.followCustomerCountRank.xAxisName'),
        },
        yAxis: {
          type: 'category',
          name: $t('views.crm.statistics.rank.chartOptions.followCustomerCountRank.yAxisName'),
          nameTextStyle: {
            align: 'left'
          }
        },
      };
    }
    case 'productSalesRank': {
      return {
        dataset: {
          dimensions: ['nickname', 'count'],
          source: cloneDeep(res).reverse(),
        },
        grid: {
          left: 20,
          right: 50,
          bottom: 20,
          containLabel: true,
        },
        legend: {
          top: 50,
        },
        series: [
          {
            name: $t('views.crm.statistics.rank.chartOptions.productSalesRank.seriesName'),
            type: 'bar',
          },
        ],
        toolbox: {
          feature: {
            dataZoom: {
              yAxisIndex: false, // 数据区域缩放：Y 轴不缩放
            },
            brush: {
              type: ['lineX', 'clear'], // 区域缩放按钮、还原按钮
            },
            saveAsImage: { show: true, name: $t('views.crm.statistics.rank.chartOptions.productSalesRank.saveAsImageName') }, // 保存为图片
          },
        },
        tooltip: {
          trigger: 'axis',
          axisPointer: {
            type: 'shadow',
          },
        },
        xAxis: {
          type: 'value',
          name: $t('views.crm.statistics.rank.chartOptions.productSalesRank.xAxisName'),
        },
        yAxis: {
          type: 'category',
          name: $t('views.crm.statistics.rank.chartOptions.productSalesRank.yAxisName'),
          nameTextStyle: {
            align: 'left'
          }
        },
      };
    }
    case 'receivablePriceRank': {
      return {
        dataset: {
          dimensions: ['nickname', 'count'],
          source: cloneDeep(res).reverse(),
        },
        grid: {
          left: 20,
          right: 50,
          bottom: 20,
          containLabel: true,
        },
        legend: {
          top: 50,
        },
        series: [
          {
            name: $t('views.crm.statistics.rank.chartOptions.receivablePriceRank.seriesName'),
            type: 'bar',
          },
        ],
        toolbox: {
          feature: {
            dataZoom: {
              yAxisIndex: false, // 数据区域缩放：Y 轴不缩放
            },
            brush: {
              type: ['lineX', 'clear'], // 区域缩放按钮、还原按钮
            },
            saveAsImage: { show: true, name: $t('views.crm.statistics.rank.chartOptions.receivablePriceRank.saveAsImageName') }, // 保存为图片
          },
        },
        tooltip: {
          trigger: 'axis',
          axisPointer: {
            type: 'shadow',
          },
        },
        xAxis: {
          type: 'value',
          name: $t('views.crm.statistics.rank.chartOptions.receivablePriceRank.xAxisName'),
        },
        yAxis: {
          type: 'category',
          name: $t('views.crm.statistics.rank.chartOptions.receivablePriceRank.yAxisName'),
          nameTextStyle: {
            align: 'left'
          }
        },
      };
    }
    default: {
      return {};
    }
  }
}
